package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SetmealDao {
    Page<Setmeal> findPage(QueryPageBean queryPageBean);

    void add(Setmeal setmeal);

    @Insert("insert into t_setmeal_checkgroup values (#{SetmealId},#{checkgroupId})")
    void addGroupIdWithSetmealId(@Param("SetmealId") Integer SetmealId, @Param("checkgroupId") Integer checkgroupId);

    @Select("select * from t_setmeal where id = #{id}")
    Setmeal findById(Integer id);

    @Select("select name setmeal from t_setmeal where id = #{setmeal_id}")
    String findByIdFromOrder(Integer setmeal_id);

    Setmeal findSetmealById(Integer id);

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id}")
    List<Integer> getGroupIds(Integer id);

    @Delete("delete from t_setmeal where id = #{id}")
    void delete(Integer id);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void delete_setmeal_checkgroup(Integer id);

    void update(Setmeal setmeal);

    @Select("select * from t_setmeal")
    List<Setmeal> findAll();

    List<Map<String,Object>> findSetmealNameAndOrderCount();

    List<Map<String,Object>> findHotSetmealNameAndOrderCount();
}
